package com.module.home.data

import com.common.app.data.repository.HomeApi.GET_ACTIVITY_ALL_SYS_FINISHED
import com.common.app.data.repository.HomeApi.UP_HEALTH_DATA
import com.common.base.data.CommonBean
import com.module.home.data.bean.UploadResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import rxhttp.toAwait
import rxhttp.wrapper.param.RxHttp

/**
 * 作者：sosou
 * <p>
 * 版本：1.0
 * <p>
 * 创建日期：2022/8/20
 * <p>
 * 描述：
 * <p>
 * 修订历史：
 */
object HomeSubApi {

    suspend fun uploadCompressedData(startDataTime: String,endDataTime: String,dataType: String,dataSize: String, firmwareVersion: String, macAddress: String, manufacturerId: String, base64EnData: String) =
        withContext(Dispatchers.IO) {
            RxHttp.postJson(UP_HEALTH_DATA)
//                .setBody(compressedData, "application/json".toMediaTypeOrNull())
//                .addHeader("X-Signature", sign)
                .addHeader("doSign", "1")
                .add("dataType", dataType)
                .add("firmwareVersion", firmwareVersion)
                .add("macAddress", macAddress)
                .add("manufacturerId", manufacturerId)
                .add("cusData", base64EnData)
                .add("startDataTime", startDataTime)
                .add("endDataTime", endDataTime)
                .add("dataSize", dataSize)
                .toAwait<CommonBean<UploadResult>>()
                .await()
        }

    suspend fun uploadSyncFinished() =
        withContext(Dispatchers.IO) {
            RxHttp.postJson(GET_ACTIVITY_ALL_SYS_FINISHED)
//                .add("dataSize", dataSize)
                .toAwait<CommonBean<Any>>()
                .await()
        }


}